package ${cfg.basePackage}.mybatis.gen.entity;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.mi.rule.db.entity.MiEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * ${table.comment!} 实体
 */
@Data
@TableName("${table.name}")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
<#if superEntityClass??>
public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
<#elseif activeRecord>
public class ${entity} extends Model<${entity}> implements MiEntity {
<#else>
public class ${entity} implements Serializable , MiEntity {
</#if>

<#if entitySerialVersionUID>
    private static final long serialVersionUID = 1L;
</#if>

<#--BEGIN 字段循环遍历-->
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
    <#if field.comment!?length gt 0>
        <#if swagger2>
    @ApiModelProperty(value = "${field.comment}")
        <#else>
    /*** ${field.comment} ***/
        </#if>
    </#if>
    <#if field.keyFlag>
        <#-- 主键 -->
        <#if field.keyIdentityFlag>
    @TableId(value = "${field.name}", type = IdType.AUTO)
        <#elseif idType??>
    @TableId(value = "${field.name}", type = IdType.${idType})
        <#elseif field.convert>
    @TableId("${field.name}")
        </#if>
        <#-- 普通字段 -->
    <#elseif field.fill??>
    <#-- -----   存在字段填充设置   ----->
        <#if field.convert>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
        <#else>
    @TableField(fill = FieldFill.${field.fill})
        </#if>
    <#elseif field.convert>
    @TableField("${field.name}")
    </#if>
    <#-- 乐观锁注解 -->
    <#if (versionFieldName!"") == field.name>
    @Version
    </#if>
    <#-- 逻辑删除注解 -->
    <#if (logicDeleteFieldName!"") == field.name>
    @TableLogic
    </#if>
    private ${field.propertyType} ${field.propertyName};

</#list>
}
//重写 hashCode  equals
//@Override
//public int hashCode() {
//if (id != null) {
//return id.hashCode();
//}
//return super.hashCode();
//}

//@Override
//public boolean equals(Object obj) {
//if (obj instanceof SysResource) {
//${entity} entity = (${entity}) obj;
//if (id != null) {
//return id.equals(entity.id);
//}
//}
//return super.equals(obj);
//}

